<!DOCTYPE html>
<html>
<head>
    <title></title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <Row :gutter="16">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="优惠券名称"/>
                </i-col>
                <i-button @click="query">查询</i-button>
            </div>
            <div class="buttons-group">
                #if($shiro.hasPermission("coupon:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("coupon:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("coupon:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
            </div>
            <!--#if($shiro.hasPermission("coupon:publish"))-->
            <!--<i-button type="primary" @click="publish">-->
            <!--<Icon type="android-send"></Icon>-->
            <!--</i>&nbsp;发放-->
            <!--</i-button>-->
            <!--#end-->
        </Row>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <Card v-show="showCard">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="coupon" :rules="ruleValidate" :label-width="100">
            <Form-item label="优惠券名称" prop="name">
                <i-input v-model="coupon.name" placeholder="优惠券名称"/>
            </Form-item>

            <Form-item label="代金卷类型" prop="sendType">
                <Radio-group v-model="coupon.type">
                    <Radio label="10">
                        <span>代金卷</span>
                    </Radio>
                    <Radio label="20">
                        <span>折扣卷</span>
                    </Radio>
                   <!-- <Radio label="30">
                        <span>商品转发送券</span>
                    </Radio>-->

                </Radio-group>
            </Form-item>
            <Form-item label="金额" prop="typeMoney"  v-if="coupon.type==10" >
                <Input-number :min="0" v-model="coupon.typeMoney" placeholder="金额" style="width: 188px;"/>
            </Form-item>
            <Form-item label="折扣（几折）" prop="typeMoney"  v-if="coupon.type==20" >
                <Input-number :min="0" v-model="coupon.rate" placeholder="金额" style="width: 188px;"/>
            </Form-item>

           <!-- <Form-item label="最小金额" prop="minAmount">
                <Input-number :min="0" v-model="coupon.minAmount" placeholder="最小金额" style="width: 188px;"/>
            </Form-item>
            <Form-item label="最大金额" prop="maxAmount">
                <Input-number :min="0" v-model="coupon.maxAmount" placeholder="最大金额" style="width: 188px;"/>
            </Form-item>-->
           <Form-item label="发放开始时间" prop="sendStartDate">
                <Date-picker v-model="coupon.sendStartDate" placeholder="发放开始时间"></Date-picker>
            </Form-item>
            <Form-item label="发放结束时间" prop="sendEndDate">
                <Date-picker v-model="coupon.sendEndDate" placeholder="发放结束时间"></Date-picker>
            </Form-item>
            <Form-item label="最低消费金额" prop="minGoodsAmount">
                <Input-number :min="0" v-model="coupon.minGoodsAmount" placeholder="最低消费金额(0或者不设置为无限制)" style="width: 188px;"/>
            </Form-item>
         <!--   <Form-item label="优惠同享" prop="sendType">
                <Radio-group v-model="coupon.ishare">
                    <Radio label="1" >
                        <span>优惠同享</span>
                    </Radio>
                    <Radio label="0" checked="true">
                        <span>不与其他优惠同享</span>
                    </Radio>
                </Radio-group>
            </Form-item>-->
            <Form-item label="领卷限制" prop="typeMoney">
                <Input-number :min="0" v-model="coupon.getlimit" placeholder="" style="width: 188px;"/>张/人
            </Form-item>
            <Form-item label="有效开始时间" prop="useStartDate">
                <Date-picker v-model="coupon.useStartDate" placeholder="有效期开始时间"></Date-picker>
            </Form-item>
            <Form-item label="有效结束时间" prop="useEndDate">
                <Date-picker v-model="coupon.useEndDate" placeholder="有效期结束时间"></Date-picker>
            </Form-item>
            <Form-item label="适用分类" prop="sendType">
                <Radio-group v-model="coupon.isgoodscategory">
                    <Radio label="1" >
                        <span>全分类</span>
                    </Radio>
                    <Radio label="0" checked="true">
                        <span>分类选择</span>
                    </Radio>
                </Radio-group>
            </Form-item>
        <!--    <Form-item label="分类选择" prop="categoryid"  v-if="coupon.isgoodscategory==0" style="width: 268px;">
                <i-input v-model="menu.parentName" @on-click="categoryTree" icon="eye" readonly="readonly"
                         placeholder="选择分类"/>

            </Form-item>-->
            <Form-item label="分类选择" v-if="coupon.isgoodscategory==0">
                <i-input v-model="coupon.parentName" @on-click="categoryTree" icon="eye" readonly="readonly"
                         placeholder="选择分类"/>
            </Form-item>

            <Form-item label="适用范围" prop="sendType">
                <Radio-group v-model="coupon.range">
                    <Radio label="1" >
                        <span>全平台</span>
                    </Radio>
                    <Radio label="0" checked="true">
                        <span>店铺选择</span>
                    </Radio>
                </Radio-group>
            </Form-item>
            <Form-item label="店铺选择" prop="brandshopid"  v-if="coupon.range==0" style="width: 268px;">
                <i-select v-model="brandshopstr" filterable multiple>
                    <i-option v-for="brandshopstr in brandshops" :value="brandshopstr.id" :key="brandshopstr.id">{{brandshopstr.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="是否积分兑换" prop="sendType">
                <Radio-group v-model="coupon.issale">
                    <Radio label="1" >
                        <span>可兑换</span>
                    </Radio>
                    <Radio label="0" checked="true">
                        <span>不能兑换</span>
                    </Radio>
                </Radio-group>
            </Form-item>

            <Form-item label="所需积分" prop="typeMoney"  v-if="coupon.issale==1" >
                <Input-number :min="0" v-model="coupon.salescore" placeholder="所需积分" style="width: 188px;"/>
            </Form-item>
            <Form-item label="成本费用" prop="typeMoney">
                <Input-number :min="0" v-model="coupon.costfee" placeholder="成本费用" style="width: 188px;"/>元
            </Form-item>
            <Form-item label="详情" prop="name">
                <i-input v-model="coupon.explain" placeholder="详情"/>
            </Form-item>
          <!--  <Form-item label="发放方式" prop="sendType">
                <Radio-group v-model="coupon.sendType">
                    <Radio label="0">
                        <span>按订单发放</span>
                    </Radio>
                    <Radio label="1">
                        <span>按用户发放</span>
                    </Radio>
                    <Radio label="2">
                        <span>商品转发送券</span>
                    </Radio>
                    &lt;!&ndash;<Radio label="3">&ndash;&gt;
                    &lt;!&ndash;<span>按商品发放</span>&ndash;&gt;
                    &lt;!&ndash;</Radio>&ndash;&gt;
                    <Radio label="4">
                        <span>新用户注册</span>
                    </Radio>
                    &lt;!&ndash;<Radio label="5">&ndash;&gt;
                    &lt;!&ndash;<span>线下发放</span>&ndash;&gt;
                    &lt;!&ndash;</Radio>&ndash;&gt;
                    <Radio label="7">
                        <span>包邮优惠</span>
                    </Radio>
                </Radio-group>
            </Form-item>-->

            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px"/>
                返回</i-button>
                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
    </Card>
    <Card id="sendDiv" v-show="showGoods">
        <i-form :label-width="100">
            <Form-item v-if="selectData.sendType == 3" label="下发商品">
                <i-select v-model="goods" filterable multiple>
                    <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}</i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="selectData.sendType == 1" label="下发会员">
                <i-select v-model="user" filterable multiple>
                    <i-option v-for="user in users" :value="user.id" :key="user.id">{{user.username}}</i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="selectData.sendType == 1" label="短信通知">
                <Checkbox v-model="sendSms">发送短信</Checkbox>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="publishSubmit">提交</i-button>
                <i-button type="warning" @click="reload"/>
                返回</i-button>
            </Form-item>
        </i-form>
    </Card>
</div>
<div id="categoryLayer" style="display: none;padding:10px;">
    <ul id="categoryTree" class="ztree"></ul>
</div>
<script src="${rc.contextPath}/js/shop/coupon.js?_${date.systemTime}"></script>
</body>
</html>